<template>
  <div>
    <van-nav-bar title="客户意向登记" left-arrow @click-left="$router.back()"/>
    <div class="initiate_main_left gzbank-style">
        <div class="bank_box">
            <div class="bank_desc">
                <label class="label">客户类型<span>*</span></label>
                <div class="bank_desc_item" style="padding: 1rem 0;">
                    <van-radio-group v-model="requestData.pslCustType" direction="horizontal">
                        <van-radio v-for="item in khlxList" :key="item.key" :name="item.key">{{item.name}}</van-radio>
                    </van-radio-group>
                </div>
            </div>
            <div class="bank_desc">
                <label class="label">客户名称<span>*</span></label>
                <div class="bank_desc_item"><input placeholder="请输入" v-model="requestData.custLglNam" /></div>
            </div>
            <div class="bank_desc">
                <label class="label">证件类型<span>*</span></label>
                <div class="bank_desc_item">
                    <ab-dict v-model="requestData.typOfIdvIdDoc" placeholder="请选择" dict-key="zjlx" checkbox="true">​</ab-dict>
                </div>
            </div>
            <div class="bank_desc">
                <label class="label">证&nbsp;&nbsp;件&nbsp;&nbsp;号</label>
                <div class="bank_desc_item">
                    <input placeholder="请输入" v-model="requestData.numOfIdvIdDoc" />
                </div>
            </div>
            <div class="bank_desc">
                <label class="label">借款金额<span>*</span></label>
                <div class="bank_desc_item"><ab-number placeholder="请输入" v-model="requestData.loanAmt" :comdify="true" decimal-place="2" coin-value=""></ab-number><span>元</span></div>
            </div>
            <div class="bank_desc">
                <label class="label">借款期限<span>*</span></label>
                <div class="bank_desc_item">
                    <!-- <input placeholder="请输入" v-model="requestData.loanDeadline" /><span>月</span> -->
                    <ab-dict v-model="requestData.loanDeadline" placeholder="请选择" dict-key="jkqx" checkbox="true">​</ab-dict>
                </div>
            </div>
            <div class="bank_desc">
                <label class="label">贷款用途<span>*</span></label>
                <div class="bank_desc_item">
                    <ab-dict v-model="requestData.loanUse" placeholder="请选择" dict-key="dkyt" checkbox="true">​</ab-dict>
                </div>
            </div>
            <!-- <div class="bank_desc">
                <label class="label">客户经理名称</label>
                <div class="bank_desc_item"><input readonly v-model="requestData.accountManagerName" /></div>
            </div>
            <div class="bank_desc">
                <label class="label">客户经理编号</label>
                <div class="bank_desc_item"><input readonly v-model="requestData.accountManagerNum" /></div>
            </div> -->
            <div class="bank_desc">
                <label class="label">手&nbsp;&nbsp;机&nbsp;&nbsp;号<span>*</span></label>
                <div class="bank_desc_item">
                    <input maxlength="11" @keyup="requestData.ctctpsnTel=requestData.ctctpsnTel.replace(/[^0-9]/g, '')" placeholder="请输入" type="text" @blur="regPhone(requestData.ctctpsnTel)" v-model="requestData.ctctpsnTel" />
                </div>
            </div>
        </div>
    </div>
    <div class="bottom_btn" @click="releaseShowClick">提交</div>
    <IntentCode v-if="modelShow" ref="IntentCode" :modelShow.sync="modelShow" :phoneNumber="requestData.ctctpsnTel" :intentionId="intentionId" ></IntentCode>
  </div>
</template>
<script>
import IntentCode from "@/view/loanPage/component/IntentCode.vue";
export default {
    name: "intentRegistration",
    data() {
        return {
            requestData: {
                "pslCustType":"",                 //客户类型
                "custLglNam":"",                //客户名称
                "typOfIdvIdDoc":"",        //证件类型        
                "numOfIdvIdDoc":"",        //身份证号
                "loanUse":"",                                //贷款用途
                "ctctpsnTel":"",                //手机号
                "accountManagerName":"",        //客户经理名称
                "accountManagerNum":"",        //客户经理编号
                "loanAmt":"",                                //借款金额
                "loanDeadline":""                                //借款期限
            },
            modelShow: false,
            intentionId: '', //意向id
            khlxList: []
        }
    },
    components: { IntentCode },
    mounted() {
    },
	created () {
        var userMsgJson = localStorage.getItem("userMsg");
        // this.requestData.accountManagerName = JSON.parse(userMsgJson).user.account;  //  客户经理名称
        // this.requestData.accountManagerNum = JSON.parse(userMsgJson).user.fullname;   //客户经理编号
        this.requestData.accountManagerName = '安智贤';  //  客户经理名称
        this.requestData.accountManagerNum = '25009';   //客户经理编号
        this.baseService.postForm(this.__ctx + '/sys/dataDict/getDictData', {dictKey: 'khlx'}).then(res => {
            this.khlxList = res.data;
        }, function (status) {
            if (status == !0) {
                this.$toast({
                    icon: 'warning',
                    message: '加载失败！' + status
                });
            }
        });
	},
	computed: {

	},
    methods: {
        releaseShowClick(){
            if(!this.requestData.pslCustType || !this.requestData.custLglNam || !this.requestData.typOfIdvIdDoc || !this.requestData.loanUse || !this.requestData.loanAmt || !this.requestData.loanDeadline || !this.requestData.ctctpsnTel){
                this.$toast({
                    icon: 'warning',
                    message: "请完善表单数据！"
                });
                return;
            }else{
                if( /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/gi.test(this.requestData.ctctpsnTel.trim()) ){
                }else{
                    this.$toast({
                        icon: 'warning',
                        message: "请输入正确手机号！"
                    });
                    return;
                }
            }
            this.$toast.loading({
                duration: 0, // 持续展示 toast
                forbidClick: true,
                message: '提交中，请稍后'
            });
            this.baseService.post(this.__ctx + '/plugin/intention/save', this.requestData).then(res => {
                this.$toast.clear();
                if (res.isOk) {
                    // this.$toast({
                    //     icon: 'success',
                    //     message: '银行卡绑定成功'
                    // });
                    this.intentionId = res.data.id;
                    this.modelShow = true;
                } else {
                    this.$toast({
                        icon: 'warning',
                        message: res.msg
                    });
                }
            }, function (status) {
                this.$toast.clear();
                if (status == !0) {
                    this.$toast({
                        icon: 'warning',
                        message: '加载失败！' + status
                    });
                }
            });
        },
        regPhone(phone) {
            this.requestData.ctctpsnTel = phone.replace(/[^0-9]/g, '');
        },
    }
  }
</script>

<style scoped lang="less">
/deep/.van-nav-bar{
  .van-nav-bar__content{
    height: 4.4rem;
    line-height: 2rem;
    .van-icon{
      color: rgb(50, 50, 51);
      font-size: 2rem;
    }
    .van-nav-bar__title{
      font-size: 1.8rem;
    }
  }
}
[class*=van-hairline]::after{
  border: 0;
}
.initiate_main_left {
    height: calc(~'100vh - 14rem');
    padding: 1.2rem 1.2rem 0;
    overflow-y: auto;

    .bank_box{
        background: #ffffff;
        border-radius: 1.2rem;
        padding: 0 1.6rem;
        .bank_desc{
            width: 100%;
            display: flex;
            justify-content: space-between;
            align-items: center;
            color: rgb(29, 33, 41);
            font-family: HarmonyOS Sans SC;
            padding: 0.8rem 0;
            border-bottom: 1px solid rgba(229, 230, 235, 0.5);
            .label{
                font-size: 1.6rem;
                line-height: 1.8rem;
                min-width: 10rem;

                span {
                    color: red;
                }
            }
            .bank_desc_item{
                // color: rgb(201, 205, 212);
                width: calc(~'100% - 11.2rem');
                font-size: 1.6rem;
                font-weight: 400;
                line-height: 1.6rem;
                letter-spacing: 0px;
                margin-left: 1.2rem;
                flex: 1;
                position: relative;
                input{
                    width: 92%;
                    height: 4rem;
                    // text-align: right;
                    border: 0;
                }
                /deep/.weui-input{
                    height: 4rem;
                }

                /deep/.select-box .showValue{
                    font-size: 1.6rem;
                    color: #1D2129;
                }

                /deep/.van-cell{
                    padding: 0;
                    .van-field__control{
                        height: 4rem;
                        // text-align: right;
                    }
                }
                >span{
                    font-size: 1.4rem;
                    position: absolute;
                    right: 0;
                    top: 50%;
                    margin-top: -0.7rem;
                }
            }
            .van-icon{
                color: rgb(201, 205, 212);
            }
        }
    }
}
.bottom_btn{
    width: calc(~'100% - 2.4rem');
    height: 4.4rem;
    margin: 1.8rem 1.2rem;
    background: linear-gradient(270.00deg, var(--primary-color), var(--gradient2-color));
    border-radius: 4rem;
    color: rgb(255, 255, 255);
    font-family: HarmonyOS Sans SC;
    font-size: 1.6rem;
    font-weight: 500;
    line-height: 4.4rem;
    letter-spacing: 0%;
    text-align: center;
    position: absolute;
    bottom: 0.6rem;
    left: 0;
}
/deep/.weui-cell_access{
    height: 4rem;
}
/deep/.van-radio__icon--checked .van-icon{
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}
</style>
<style>
.initiate_main_left .bank_desc .not-border .input-box{
    input{
        text-align: right;
    }
    a{
        color: var(--primary-color)!important;
    }
}
</style>